<?php
// +----------------------------------------------------------------------
// | Description: 系统用户
// +----------------------------------------------------------------------
// | Author: linchuangbin <linchuangbin@honraytech.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;

class User extends ApiCommon
{

    public function login()
    {   
        $userModel = model('User');
        $param = $this->param;
        $data = $userModel->login($param);
        if(!$data)
        {
            return resultArray(['error'=>$userModel->getError()]);
        }
        return resultArray(['data'=>'登录成功']);
    }

    public function getmenu()
    {
        $memberModel=Model('User');
        $param=$this->param;
        $data=$memberModel->getmenu($param);
        return resultArray(['data'=> $data]);
    }
    
    public function userWrite(){
        $newsModel = model('User');
        $param=$this->param;
        $data=$newsModel->userWrite($param);
        if(!$data)
        {

            return resultArray(['error'=>$newsModel->getError()]);
        }
        return resultArray(['data'=>'添加成功']); 
    }

    public function userEdit(){
        $newsModel = model('User');
        $param=$this->param;
        $data=$newsModel->userEdit($param);
        if(!$data)
        {

            return resultArray(['error'=>$newsModel->getError()]);
        }
        return resultArray(['data'=>'修改成功']); 
    }

    public function userDelete(){
        $newsModel = model('User');
        $param=$this->param;
        $data=$newsModel->userDelete($param);
        if(!$data)
        {

            return resultArray(['error'=>$newsModel->getError()]);
        }
        return resultArray(['data'=>'删除成功']); 
    }

    public function getuser()
    {
        $memberModel=Model('User');
        $param=$this->param;
        $data=$memberModel->getuser($param);
        return resultArray(['data'=> $data]);
    }

    public function getuserbyId()
    {
        $memberModel=Model('User');
        $param=$this->param;
        $data=$memberModel->getuserbyId($param);
        return resultArray(['data'=> $data]);
    }
}
 